package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

import java.util.Arrays;

/**
 * 成绩状态枚举
 *
 * 定义成绩处理过程中的各种状态
 *
 * @author System
 * @version 1.0.0
 */
public enum GradeStatus implements BaseEnum {

    /** 草稿 */
    DRAFT("DRAFT", "草稿"),

    /** 初始状态 */
    INITIAL("INITIAL", "初始状态"),

    /** 计算中 */
    CALCULATING("CALCULATING", "计算中"),

    /** 已计算 */
    CALCULATED("CALCULATED", "已计算"),

    /** 待审核 */
    PENDING_REVIEW("PENDING_REVIEW", "待审核"),

    /** 审核中 */
    UNDER_REVIEW("UNDER_REVIEW", "审核中"),

    /** 已审核 */
    REVIEWED("REVIEWED", "已审核"),

    /** 已确认 */
    CONFIRMED("CONFIRMED", "已确认"),

    /** 已发布 */
    PUBLISHED("PUBLISHED", "已发布"),

    /** 已锁定 */
    LOCKED("LOCKED", "已锁定"),

    /** 错误状态 */
    ERROR("ERROR", "错误状态"),

    /** 已取消 */
    CANCELLED("CANCELLED", "已取消"),

    /** 过期 */
    EXPIRED("EXPIRED", "过期"),

    /** 归档 */
    ARCHIVED("ARCHIVED", "归档");

    private final String code;
    private final String description;

    GradeStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static GradeStatus fromCode(String code) {
        return Arrays.stream(values())
                .filter(e -> e.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("Unknown grade status code: " + code));
    }
    @Override
    public String toString() {
        return description;
    }
}